<%-- 
    Document   : index
    Created on : Dec 13, 2009, 4:10:43 PM
    Author     : Jeremy
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.List" %>
<%@ page import="jhu.profiteer.data.GameConfigurationParameters" %>
<%@ page import="jhu.profiteer.data.GameConfigurationParametersJpaController" %>
<%@ page import="jhu.profiteer.data.Location" %>
<%@ page import="jhu.profiteer.data.LocationJpaController" %>

<%@ include file="/WEB-INF/jspf/admin/auth.jspf" %>
<html>
  <%
    String pageTitle = "Administration Homepage - Game Configuration Parameters";
    String cssFile = "/profiteer-game/css/profiteer.css";

    GameConfigurationParametersJpaController jc =
            new GameConfigurationParametersJpaController();
    GameConfigurationParameters gcp = jc.findGameConfigurationParameters();
  %>
  <%@ include file="/WEB-INF/jspf/admin/header.jspf" %>
  <body>
    <%@ include file="/WEB-INF/jspf/title.jspf" %>
    <div class="contentArea Body">
      <div class="pagetitle">Administration</div>
      <div class="pagebody">
        <table>
          <tr>
            <td id="menu"><%@ include file="/WEB-INF/jspf/admin/sidebar.jspf" %></td>
            <td>
              <div class="divround">
                <%@ include file="/WEB-INF/jspf/admin/notice.jspf" %>
                <form action="processGCP" method="post">
                  <% if (null != gcp) { %><input type="hidden" name="gcpId" value="<%= gcp.getId() %>" /><% } %>
                  <table>
                    <tr>
                      <td>Initial Money:</td>
                      <td><input type="text" name="initialMoney" <% if(null != gcp) { %> value="<%= gcp.getInitialMoney() %>" <% } %>/></td>
                    </tr>
                    <tr>
                      <td>Initial Location:</td>
                      <td>
                        <select name="initialLocationId">
                          <%
                            LocationJpaController ljc = new LocationJpaController();
                            List<Location> locations = ljc.findLocationEntities();

                            if((null == locations) || (locations.size() == 0))
                            {
                          %>
                          <option value="0">Default (0)</option>
                          <%
                            }
                            else
                            {
                              for(Location l : locations)
                              {
                          %>
                          <option value="<%= l.getId() %>" <% if((null != gcp) && (gcp.getInitialLocationId().equals(l.getId()))) { %> selected="selected" <% } %>><%= l.getName() %></option>
                          <%
                              }
                            }
                          %>
                        </select>
                      </td>
                    </tr>
                    <tr>
                      <td>Initial Fuel:</td>
                      <td><input type="text" name="initialFuel" <% if(null != gcp) { %> value="<%= gcp.getInitialFuel() %>" <% } %>/></td>
                    </tr>
                    <tr>
                      <td>Initial Cargo Capacity:</td>
                      <td><input type="text" name="initialCargoCapacity" <% if(null != gcp) { %> value="<%= gcp.getInitialCargoCapacity() %>" <% } %>/></td>
                    </tr>
                    <tr>
                      <td>Fuel Cost:</td>
                      <td><input type="text" name="fuelCost" <% if(null != gcp) { %> value="<%= gcp.getFuelCost() %>" <% } %>/></td>
                    </tr>
                  </table>
                  <input type="submit" name="submit" <% if(null == gcp) { %> value="Create" <% } else { %> value="Update" <% } %> />
                </form>
              </div>
            </td>
          </tr>
        </table>
      </div>
    </div>
    <%@ include file="/WEB-INF/jspf/footer.jspf" %>
  </body>
</html>